	#include <stdio.h>   /* Standard input/output definitions */
	#include <string.h>  /* String function definitions */
	#include <unistd.h>  /* UNIX standard function definitions */
	#include <fcntl.h>   /* File control definitions */
	#include <errno.h>   /* Error number definitions */
	#include <termios.h> /* POSIX terminal control definitions */

	/*
	* 'open_port()' - Open serial port 1.
	*
	* Returns the file descriptor on success or -1 on error.
	*/

	int
	open_port(const char *file)
	{
		int fd; /* File descriptor for the port */


		fd = open(file, O_RDWR | O_NOCTTY );
		if (fd == -1)
		{
			/*
			* Could not open the port.
			*/

			perror("open_port: Unable to open file");
		}

		return (fd);
	}

	void serial_init(int fd)//, int baud)
	{
		struct termios options;

		/*
		* Get the current options for the port...
		*/

		tcgetattr(fd, &options);

		/*
		* Set the baud rates to 2400, 9600, 19200, 38400
		*/

		cfsetspeed(&options, B115200);
		cfmakeraw(&options);

		/*
		* Enable the receiver and set local mode...
		*/

		options.c_cflag |= (CLOCAL | CREAD);

		//No Parity Checking
		options.c_cflag &= ~PARENB;
		options.c_cflag &= ~CSTOPB;
		//Bits to send
		options.c_cflag &= ~CSIZE; /* Mask the character size bits */
	    	options.c_cflag |= CS8;    /* Select 8 data bits */

	
		//
		//options.c_cflag |= CRTSCTS;    /* Also called CRTSCTS */	

		/*
		* Set the new options for the port...
		*/

		tcsetattr(fd, TCSANOW, &options);
		tcflush(fd, TCIOFLUSH);
	}
